<template>
    <div class="usercenter">
        <div class="header">
            <div class="header_title">
                <div class="title_avatar">
                    <img :src="LoginUser.avatar" alt="">
                </div>
                <div class="title_content">
                    <div class="content_text">{{ LoginUser.nickname }}</div>
                    <div class="content_sm">{{ LoginUser.createtime }}</div>
                </div>
            </div>
            <div class="operate">
                <div class="text-sm">
                    <span class="text-bold">{{ LoginUser.collectionCount }}</span>
                    收藏夹
                </div>
                <div class="text-sm">
                    <span class="text-bold">{{ LoginUser.money }}</span>
                    余额
                </div>
                <div class="text-sm">
                    <span class="text-bold">{{ LoginUser.receiveCount }}</span>
                    优惠券数量
                </div>
                <div class="text-sm">
                    <span class="text-bold">{{ LoginUser.orderCount }}</span>
                    订单数量
                </div>
            </div>
        </div>
        <div class="userorder">
            <div class="order_project">
                <div class="item">
                    <router-link to="/order/index" class="item">
                        <div class="img">
                            <img src="/assets/images/order1.png" alt="">
                        </div>
                        待支付
                    </router-link>
                </div>
                <div class="item">
                    <router-link to="/order/index" class="item">
                        <div class="img">
                            <img src="/assets/images/order2.png" alt="">
                        </div>
                        待发货
                    </router-link>
                </div>
                <div class="item">
                    <router-link to="/order/index" class="item">
                        <div class="img">
                            <img src="/assets/images/order3.png" alt="">
                        </div>
                        待收货
                    </router-link>
                </div>
                <div class="item">
                    <router-link to="/order/index" class="item">
                        <div class="img">
                            <img src="/assets/images/order4.png" alt="">
                        </div>
                        待评价
                    </router-link>
                </div>
                <div class="item solid-left">
                    <router-link to="/order/index" class="item">
                        <div class="img">
                            <img src="/assets/images/returns.png" alt="">
                        </div>
                        退货/售后
                    </router-link>
                </div>
            </div>
        </div>
        <div class="userorder">
            <div class="order_project">
                <div class="item">
                    <router-link to="/business/poster" class="item">
                        <div class="img"> <img src="/assets/images/retail1.png" alt=""></div>
                        分销信息
                    </router-link>
                </div>
                <div class="item">
                    <router-link to="/business/member" class="item">
                        <div class="img"> <img src="/assets/images/retail2.png" alt=""></div>
                        分销会员
                    </router-link>
                </div>
                <div class="item">
                    <router-link to="/business/commission" class="item">
                        <div class="img"> <img src="/assets/images/retail3.png" alt=""></div>
                        分销佣金
                    </router-link>
                </div>
                <div class="item">
                    <router-link to="/business/coupon" class="item">
                        <div class="img"> <img src="/assets/images/coupon.png" alt=""></div>
                        优惠列表
                    </router-link>
                </div>
                <div class="item solid-left">
                    <router-link to="/business/deposit" class="item">
                        <div class="img"> <img src="/assets/images/recharge2.png" alt=""></div>
                        充值中心
                    </router-link>
                </div>
            </div>
        </div>
        <div class="usertool">
            <div class="list">
                <div class="item">
                    <a href="javascript:void(0)" @click="toPages('/business/profile')">
                        <div class="img">
                            <img src="/assets/images/profile.png" alt="">
                        </div>
                        基本资料
                    </a>
                </div>
                <div class="item">
                    <a href="javascript:void(0)" @click="toPages('/teamorder/index')">
                        <div class="img"> <img src="/assets/images/pingtuan.png" alt=""></div>
                        拼团订单
                    </a>
                </div>
                <div class="item">
                    <a href="javascript:void(0)" @click="toPages('/business/address/index')">
                        <div class="img"> <img src="/assets/images/address.png" alt=""></div>
                        收货地址
                    </a>
                </div>
                <div class="item">
                    <a href="javascript:void(0)" @click="toPages('/business/email')">
                        <div class="img"> <img src="/assets/images/email.png" alt=""></div>
                        邮箱认证
                    </a>
                </div>
                <div class="item">
                    <a href="javascript:void(0)" @click="toPages('/business/record')">
                        <div class="img"> <img src="/assets/images/consume.png" alt=""></div>
                        消费记录
                    </a>
                </div>
                <div class="item">
                    <a href="javascript:void(0)" @click="toPages('/business/rechange')">
                        <div class="img"> <img src="/assets/images/recharge1.png" alt=""></div>
                        充值记录
                    </a>
                </div>
                <div class="item">
                    <a href="javascript:void(0)" @click="toPages('')">
                        <div class="img"> <van-icon name="clear" color="#ee0a24" /></div>
                        退出登陆
                    </a>
                </div>
            </div>
        </div>
        <div class="usertool">
            <ul class="proul">
                <li v-for="item in info" :key="item.id">
                    <router-link :to="{ path: '/product/info', query: { proid: item.product.id } }"><img
                            :src="item.product.thumbs_text" /></router-link>
                    <router-link :to="{ path: '/product/info', query: { proid: item.product.id } }">
                        <p class="tit">{{ item.product.name }}</p>
                    </router-link>
                    <div class="price">
                        <p>￥{{ item.price }}</p>
                    </div>
                </li>

            </ul>
        </div>
        <div class="h54"></div>
        <div class="clear"></div>
    </div>
    <Footer />
</template>
<script setup>
import Footer from '@/components/common/footer.vue';
const { proxy } = getCurrentInstance()
const LoginUser = reactive(proxy.$cookies.get('LoginUser'));
const info = ref({})
onBeforeMount(() => {
    cont()
})
const toPages = (url) => {
    if (url) {
        if (LoginUser.auth == '1' && url == '/business/email') {
            success('邮箱已认证，无需再认证')
            return false;
        }
        proxy.$router.push(url)
    } else {
        Confirmdialog({
            title: '退出',
            message:
                '确认是否退出登陆?',
        })
            .then(() => {
                //删除
                proxy.$cookies.remove("LoginUser");
                success({
                    message: '退出成功',
                    onClose: () => {
                        proxy.$router.push('/business/login')
                    }
                });
            })
            .catch(() => { });
    }
}
const cont = async () => {
    let result = await Api.Cont({
        busid: LoginUser.id,
    })
    if (result.code == 1) {
        info.value = result.data
        console.log(info.value)
    }
}
</script>
<style>
@import url('/assets/css/my.css');
</style>